const ImageColorUtil = (src) => {
    let image = new Image();
    image.src = src;

    return new Promise((resolve, reject) => {
        image.onerror = reject
        image.onload = function () {
            let palette = new Palette(image);

            try {
                let temp = {
                    DominantColor: palette['getDominantColor'](),
                    VIBRANT: palette['getVibrantColor'](),
                    LIGHT_VIBRANT: palette['getLightVibrantColor'](),
                    DARK_VIBRANT: palette['getDarkVibrantColor'](),
                    MUTED: palette['getMutedColor'](),
                    LIGHT_MUTED: palette['getLightMutedColor'](),
                    DARK_MUTED: palette['getDarkMutedColor'](),
                    primary: () => temp.VIBRANT || temp.LIGHT_VIBRANT || temp.DARK_VIBRANT,
                    secondary: () => temp.MUTED || temp.LIGHT_MUTED || temp.DARK_MUTED
                }
                resolve(temp)
            } catch (e) {
                reject(e)
            }
        }
    })
}
export default ImageColorUtil